<?php 
include_once("includes/foxydb.php");
include_once("includes/config.php");

global $TOP_CONTENT_CATEGORY_SID,$TOP_AREA_CATEGORY_SID ;

$foxydb = new Foxydb();

$pcatsid = $_REQUEST['catsid'];

if(!$pcatsid) $pcatsid = $TOP_CONTENT_CATEGORY_SID; //top content category sid

$foxydb->open();
$primaryPath = $foxydb->findCategoryPrimaryPath($pcatsid);
$childCats = $foxydb->getChildCategories($pcatsid);

$isByContentCat = false;
if($primaryPath){
	$topcat = $primaryPath[count($primaryPath)-1];
	if($topcat['sid'] == $TOP_CONTENT_CATEGORY_SID) $isByContentCat = true;

  $sites = $foxydb->selectSitesByCatSid($pcatsid,100);
}
$foxydb->close();

include_once("includes/header.php");
?>
  <TABLE width="100%" cellpadding=2 cellspacing=0 border=0>
  <TR><TD colspan='2' align=right><?php include_once("includes/menu.php");?></TD></TR>
  <TR>
	<TD colspan="2">
		<TABLE width="100%" cellpadding=0 cellspacing=0 border=1>
		<TR>
			<TD><font size="+1"><b>当前位置&gt;&gt;
                <?php for ($i=count($primaryPath)-1;$i>=0;$i--) { 
                  $cat = $primaryPath[$i];
                  ?>
                <a href="list.php?catsid=<?php echo $cat['sid']; ?>"><?php echo $cat['name']; ?></a>: 
                <?php } ?>
			</b></font></TD>
			<TD width="1%" nowrap>
			<?php if($isByContentCat){?>
				按<a href="list.php?catsid=<?php echo $TOP_AREA_CATEGORY_SID; ?>">地区</a>/内容浏览
      <?php }else{?>
				按地区/<a href="list.php?catsid=<?php echo $TOP_CONTENT_CATEGORY_SID; ?>">内容</a>浏览
      <?php }?>
      </TD>
		</TR>
		</TABLE>
	</TD>
  </TR>
  <TR>
	<TD width="120px" valign='top' align="right">
		<TABLE width="100%" cellpadding=0 cellspacing=0  border=1>
      <?php 
      if($childCats && count($childCats) > 0){
        foreach($childCats as $cat){ 
      ?>
          <tr>
            <td valign=top nowrap='true'><A href="list.php?catsid=<?php echo $cat['sid']; ?>"><b><?php echo $cat['name']; ?></b></A></td>
          </tr>
      <?php }
      }?>
		</TABLE>
	</TD>

	<TD valign="top">
		<TABLE width="100%" cellpadding=0 cellspacing=0  border=1>
		<TR>
			<TD width="99%" align="center"><font size="-1">网址介绍</font></TD>
			<TD nowrap><font size="-1">网址积分</font></TD>
			<TD nowrap><font size="-1"><A href='admin/editfavoritesites.php'>常用<br/>网址</A></font></TD>
		</TR>
		<FORM action='admin/editfavoritesites.php' method='POST' >
		<?php 
		if($sites && count($sites) > 0){
		  foreach($sites as $s){ 
		?>
		  <TR>
			<TD><A href="<?php echo $s['uri']; ?>" target=_blank><?php echo $s['name']; ?></A>&nbsp;&nbsp;<?php echo $s['description']; ?> </TD>
			<TD><?php echo $s['ranking']; ?></TD>
			<TD><INPUT type='checkbox' name='chksitesid[]' value='<?php echo $s['sid']; ?>'></TD>
		  </TR>
		<?php }
		}?>

		<TR>
			<TD width="99%" align="center"><font size="-1">网址介绍</font></TD>
			<TD nowrap><font size="-1">网址积分</font></TD>
			<INPUT type='hidden' name='action' value='add'>
			<TD nowrap><INPUT type='submit' name='submit' value='定制'></TD>
		</TR>
		</FORM>
		</TABLE>
	</TD>
  </TR>
  </TABLE>


<?php include("includes/footer.php");?>